﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace 录音客户端
{
    public partial class serverInfo : Form
    {
        public serverInfo()
        {
            InitializeComponent();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            string server = txbip.Text;
            string port = txbport.Text;
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.AppSettings.Settings.Clear();
            config.AppSettings.Settings.Add("ServerIP", server);
            config.AppSettings.Settings.Add("Port", port);

            // Save the configuration file.    
            config.AppSettings.SectionInformation.ForceSave = true;
            config.Save(ConfigurationSaveMode.Modified);
            // Force a reload of the changed section.    
            ConfigurationManager.RefreshSection("appSettings");
            MessageBox.Show("保存成功！");
            this.Close();
        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void serverInfo_Load(object sender, EventArgs e)
        {
            this.txbport.Text = ConfigurationManager.AppSettings["port"];//端口
            this.txbip.Text = ConfigurationManager.AppSettings["ServerIP"];//服务器IP
        }
    }
}
